<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ include file="../../common/layui.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
</head>
<body>
<!-- 弹出页 -->
<form class="layui-form" id="model" style="padding-top: 10px;">

    <!-- 对应表单的ID -->
    <input id="id" readonly="readonly" name="fromId" value="${model.id}"/>
    <!-- 流程定义ID-->
    <input id="flowDepId" readonly="readonly" type="text" name="flowDepId" value="${model.flowDepId}"/>

    <!--  上一节点 的节点ID -->
    <input id="nodeId" readonly="readonly" type="text" name="LastNodeId" value="${model.nodeId}"/>
    <!-- 上一节点 的节点名称-->
    <input id="flowName" readonly="readonly" type="text" name="LastNodeName" value="${model.flowName}"/>
    <!-- 单个流程ID-->
    <input id="flowId" readonly="readonly" type="text" name="flowId" value="${model.flowId}"/>
    <!-- 单个流程taskId-->
    <input id="taskId" readonly="readonly" type="text" name="taskId" value="${model.taskId}"/>

    <!-- 内容 -->
    <div class="manage_text2">

        <div class="layui-form-item manage-form-item" >
            <label class="layui-form-label manage_text_bt"><span>部门</span></label>
            <input class="layui-input newsName manage_text_input"  readonly="readonly" value="${model.depart}"/>
        </div>

        <div class="layui-form-item manage-form-item">
            <label class="layui-form-label manage_text_bt"><span>开始时间</span></label>
            <input class="layui-input newsName manage_text_input"readonly="readonly" value="${model.startTime}"/>
        </div>

        <div class="layui-form-item manage-form-item">
            <label class="layui-form-label manage_text_bt"><span>结束时间</span></label>
            <input class="layui-input newsName manage_text_input" readonly="readonly" value="${model.endTime}"/>
        </div>

        <div class="layui-form-item manage-form-item">
            <label class="layui-form-label manage_text_bt"><span>原因</span></label>
            <textarea class="layui-input newsName manage_text_input" style="height: 150px;"  readonly="readonly" >${model.reason}</textarea>
        </div>

        <hr/>

        <div class="layui-form-item manage-form-item">
            <label class="layui-form-label manage_text_bt"><span>审核意见：</span></label>
            <!-- 是审核通过还是审核不通过 -->
            <input name="state" id="state" value="" />
            <textarea class="layui-input newsName manage_text_input" style="height: 150px;" id="opinion" name="opinion" ></textarea>
        </div>

        <div class="details_buttons">
            <button class="layui-btn btn_color_lvse" style="margin-left: 30px;" type="button"  onclick="audit('y')">进入下一环节</button>
            <button class="layui-btn btn_color_hongse" style="margin-left: 30px;" type="button"   onclick="audit('n')">退回</button>
            <button class="layui-btn layui-btn-primary"  style="margin-left: 30px;" type="button" onclick="parent.layer.closeAll();">返回上级</button>
        </div>



    </div>
</form>

<script type="text/javascript">


    function audit(state) {

        var flag = false;//防止多次点击
        parent.layer.confirm("确认当前操作吗？", {
            btn : [ '确定', '取消' ]//按钮
        }, function(index) {
            if(flag==true){//说明执行过了ajax
                return false;//不在执行第二次了
            }
            flag = true;
            $("#state").val(state);//审核通过 y 不通过 n

            parent.layer.close(index);
            var index2 = parent.layer.msg('加载中', {
                icon: 16,
                shade: 0.01
            });
            //延迟执行提交，防止关闭confirm不生效
            setTimeout(function(){
                var formData = new FormData($("#model" )[0]);
                $.ajax({
                    url: "flow/complete",
                    type:"POST",
                    cache:false,
                    async:false,
                    processData: false,
                    contentType: false,
                    data:formData,
                    dataType:"json",
                    success:function(data){
                        parent.layer.close(index2);
                        parent.layer.msg('操作成功！', {icon: 1});
                        setTimeout(reloadParent,500);
                    }
                });
            }, 500);
        });



    }



    /**刷新父页面的方法 */
    function  reloadParent() {
        var parentwin = window.parent.document.getElementsByTagName("iframe")[2].contentWindow;//父级窗口刷新
        parentwin.reloadTable();//这个要保证，调用页面都有reloadTable()这个函数
        parentwin.location.reload();
        parentwin.parent.layer.closeAll();
    }


</script>
</body>
</html>
